package cn.jsp;

import cn.jsp.domain.Stu;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import cn.jsp.dao.BaseDao;
import java.io.IOException;
import java.util.List;

@WebServlet("/generalRowProcessor")
public class GeneralRowProcessorServlet extends HttpServlet {
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ApplicationContext ctx= WebApplicationContextUtils.getRequiredWebApplicationContext(req.getServletContext());
    BaseDao dao=ctx.getBean(BaseDao.class);
    List<Stu> stus=dao.find("select * from stu",Stu.class);
    resp.getWriter().println(stus);
  }
}
